Function.RegisterNamespace("System.IO.FileStrategy");

System.IO.FileStrategy.Node=function(){
    var _bufferSize=1024*1024;
    var fs=null;


    // IFileStrategy Members
    this.DeleteFile=function(path){
        if(this.Exists(path)){
            fs.unlinkSync(path);
        }
        return false;
    };
    
    this.Exists=function(path){
        if(!!path){
            return fs.existsSync(path)&&fs.statSync(path).isFile();
        }
        return false;
    };

    this.GetFile=function(path){
        if(this.Exists(path)){
            return fs.readFileSync(path);
        }
        return null;
    };
        
    this.SaveFile=function(path,text){
        fs.writeFileSync(path,text);
    };

    // IStrategySpecification Members
    this.IsSatisfiedBy=function(candidate){
        if(Object.Global()==Object.Global().global&&typeof(process)!="undefined"&&typeof(require)=="function"){
            fs=require("fs");
            return true;
        }
        return false;
    };

};

System.IO.FileStrategy.Node.Implement(System.IO.FileStrategy.IFileStrategy,'System.IO.FileStrategy.Node');
System.IO.FileStrategy.Node.Implement(System.Script.Strategy.IStrategySpecification,'System.IO.FileStrategy.Node');

System.IO.File.Strategies.Add(System.IO.FileStrategy.Node);